<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统级取色器</title>
    <link rel="stylesheet" href="../../src/style/dd-css/dd-init.css">
    <script src="../../index.js"></script>
</head>

<body>
    <div class="box dd-row dd-v-center">
        <button class="startBtn dd-btn dd-btn-red">开始取色</button>
        <input class="inputDom dd-input" type="text">
        <div class="colorBox"></div>
    </div>

    <style>
        .box {
            width: 220px;
            margin: 20px auto;
        }

        .startBtn {
            height: 34px;
        }

        .colorBox {
            width: 20px;
            height: 20px;
            background: #ccc;
            margin-left: 8px;
            box-shadow: #ccc 0px 0px 5px;
        }
    </style>
    <script>
        let startBtn = document.querySelector('.startBtn');
        let inputDom = document.querySelector('.inputDom');
        let colorBoxDom = document.querySelector('.colorBox');

        startBtn.onclick = async () => {
            const dropper = new EyeDropper();
            try {
                const result = await dropper.open()
                let text = result.sRGBHex
                inputDom.value = text;
                colorBoxDom.style.background = text;
                spanman.copy2ClipBoard(text);
            } catch (error) {
                console.log("7777 ---- file: index.html:35 ---- error---->", error)
            }
        }
    </script>
</body>

</html>